srgb_to_lab_u8 \
sanity \
babl_class_name \
- conversions \
types \
- models \
- formats
+ models
TESTS_ENVIRONMENT = BABL_PATH=$(top_builddir)/extensions
babl_class_name_SOURCES = babl_class_name.c
sanity_SOURCES = sanity.c
types_SOURCES = types.c
+babl_fish_path_fitness_SOURCES = babl_fish_path_fitness.c
+babl_fish_path_dhtml_SOURCES = babl_fish_path_dhtml.c
formats_SOURCES = formats.c
models_SOURCES = models.c
LDADD = $(top_builddir)/babl/libbabl.la -lm ${dl}
-noinst_PROGRAMS = \
- introspect \
- babl_html_dump \
- nop \
+noinst_PROGRAMS = \
+ introspect \
+ babl_fish_path_fitness \
+ babl_fish_path_dhtml \
+ babl_html_dump \
+ conversions \
+ formats \
+ nop \
$(TESTS)
introspect_SOURCES = introspect.c
babl_type_each (show_item, NULL);
babl_model_each (show_item, NULL);
babl_format_each (show_item, NULL);
- babl_conversion_each (show_item, NULL);
+/* babl_conversion_each (show_item, NULL);*/
printf ("'>+</a>");
printf ("<a href='javascript:");
babl_type_each (hide_item, NULL);
babl_model_each (hide_item, NULL);
babl_format_each (hide_item, NULL);
- babl_conversion_each (hide_item, NULL);
+ /*babl_conversion_each (hide_item, NULL);*/
printf ("'>-</a>");
printf ("<div class='expander'>");
printf ("</div>\n");
printf ("</div>\n");
-
+/*
printf ("<div class='expander'>");
printf ("<div class='expander_title'><a style='font-size:110%%' name='Conversions' href='javascript:toggle_visible(\"x_conversions\")'>Conversions</a></div><div class='expander_content' id='x_conversions'>\n");
babl_conversion_each (each_item, NULL);
printf ("</div>\n");
printf ("</div>\n");
-
+*/
babl_destroy ();
return 0;
--- /dev/null
+/* perform a symmetricality of conversion test on a set of randomized
+ * RGBA data */
+
+#include <stdlib.h>
+#include <math.h>
+#include "babl-internal.h"
+
+#define pixels 1024
+int total_length=0;
+int total_cost=0;
+int total = 0;
+int ok = 0;
+
+static double test[pixels * 4];
+
+static void
+test_init (void)
+{
+ int i;
+
+ for (i = 0; i < pixels * 4; i++)
+ test [i] = (double)random () / RAND_MAX;
+}
+
+static int qux=0;
+
+static char *utf8_bar[]={" ","·","▁","▂","▃","▄","▅","▆","▇","█"};
+//static char *utf8_bar[]= {"!","▁","▃","▅","▇","█","!","!","!"};
+//static char *utf8_bar[]={"·", "█", "▇", "▆", "▅", "▄", "▃", "▂", "▁", };
+//static char *utf8_bar[]={" ","1","2","3","4","5","6","7","8"};
+
+static int
+table_destination_each (Babl *babl,
+ void *userdata)
+{
+ Babl *source = userdata;
+ Babl *destination = babl;
+
+ if ((qux++) % babl_formats_count () == qux/ babl_formats_count ())
+ printf ("<td class='cell'> </td>");
+ else
+ {
+ Babl *temp = babl_fish_path (source, destination);
+
+ if (temp)
+ {
+ printf ("<td class='cell'><a onmouseover='show(\"detail_%p\");' \
+ onmouseout='hide(\"detail_%p\");' \
+ href='javascript:tick()'>%s</a></td>",
+ temp, temp, utf8_bar[temp->fish_path.conversions]);
+ total_length += temp->fish_path.conversions;
+ total_cost += temp->fish_path.cost;
+ ok ++;
+ total ++;
+ }
+ else
+ {
+ printf ("<td class='cell'><a onmouseover='show(\"detail_%p_%p\");' \
+ onmouseout='hide(\"detail_%p_%p\");' \
+ href='javascript:tick()'>%s</a></td>",
+ source, destination,
+ source, destination,
+ " ");
+ }
+ }
+ return 0;
+}
+
+static int source_no=0;
+
+static int
+table_source_each (Babl *babl,
+ void *userdata)
+{
+ char expanded_name[512];
+ const char *s;
+ char *d;
+
+ s=babl->instance.name;
+ d=&expanded_name[0];
+
+ while (*s)
+ {
+ switch (*s)
+ {
+ case ' ':
+ *(d++)='&';
+ *(d++)='n';
+ *(d++)='b';
+ *(d++)='s';
+ *(d++)='p';
+ *(d++)=';';
+ *(d) ='\0';
+ s++;
+ break;
+ default:
+ *(d++)=*(s++);
+ *(d) ='\0';
+ break;
+ }
+ }
+
+ printf ("<tr>");
+ printf ("<td class='format_name'><a onmouseover='show(\"format_%p\");' \
+ onmouseout='hide(\"format_%p\");' \
+ href='javascript:tick();'>%s</a></td>",
+ babl, babl, expanded_name);
+ babl_format_each (table_destination_each, babl);
+ printf ("</tr>\n");
+ source_no++;
+ return 0;
+}
+
+
+
+static int
+detail_destination_each (Babl *babl,
+ void *userdata)
+{
+ Babl *source = userdata;
+ Babl *destination = babl;
+
+ Babl *temp = babl_fish_path (source, destination);
+
+ if (temp)
+ {
+ int i;
+ printf ("<div class='detail' style='display:none' id='detail_%p'>", temp);
+ printf ("<h3><span style='color:gray'>path</span> %s <span style='color:gray'>to</span> %s</h3>", source->instance.name, destination->instance.name);
+ printf ("<table>\n");
+ printf ("<tr>");
+ printf ("<td><em>conversion</em></td>");
+ printf ("<td style='text-align:right'><em>cost</em></td>");
+ printf ("</tr>");
+ for (i=0; i< temp->fish_path.conversions; i++)
+ {
+ printf ("<tr>");
+ printf ("<td>%s</td>", BABL(temp->fish_path.conversion[i])->instance.name);
+ printf ("<td style='text-align:right'>%i</td>", BABL(temp->fish_path.conversion[i])->conversion.cost);
+ printf ("</tr>");
+ }
+ printf ("<tr>");
+ printf ("<td><em>total</em></td>");
+ printf ("<td style='text-align:right'><em>%3.0f</em></td>", temp->fish_path.cost);
+ printf ("</tr>");
+ printf ("</table>\n");
+ printf ("</div>\n");
+ }
+ else
+ {
+ printf ("<div class='detail' style='display:none' id='detail_%p_%p'>", source, destination);
+ printf ("<h3><span style='color:gray'>Reference</span> %s <span style='color:gray'>to</span> %s</h3>", source->instance.name, destination->instance.name);
+ printf ("</div>\n");
+ }
+ return 0;
+}
+
+static int
+detail_source_each (Babl *babl,
+ void *userdata)
+{
+ babl_format_each (detail_destination_each, babl);
+ return 0;
+}
+
+static int
+format_each (Babl *babl,
+ void *userdata)
+{
+ int i;
+
+ printf ("<div class='detail' style='display:none' id='format_%p'>", babl);
+ printf ("<h3>%s</h3>", babl->instance.name);
+
+ printf ("<dl>");
+ printf ("<dt>bytes/pixel</dt><dd>%i</dd>", babl->format.bytes_per_pixel);
+ printf ("<dt>model</dt><dd>%s</dd>", BABL(babl->format.model)->instance.name );
+ printf ("<dt>loss</dt><dd>%f</dd>", babl->format.loss );
+ printf ("<dt>components</dt><dd><table class='nopad'>");
+
+ for (i=0; i< babl->format.components; i++)
+ {
+ printf ("<tr><td class='type'>%s</td><td class='component'>%s</td></tr>",
+ BABL(babl->format.type[i])->instance.name,
+ BABL(babl->format.component[i])->instance.name );
+ }
+ printf ("</table></dd></dl>");
+
+ printf ("</div>\n");
+ return 0;
+}
+
+
+int main (void)
+{
+ babl_init ();
+ test_init ();
+
+ babl_set_extender (babl_extension_quiet_log ());
+
+ printf (
+"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
+"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
+"<html>\n"
+"<head>\n"
+"<title>BablFishPath introspection</title>\n"
+
+ "<style type='text/css'>"
+ " body {"
+ " font-family: sans;"
+ " margin-left: 1em;"
+ " }"
+ " .cell {"
+ " overflow : none;"
+ " height: 1em;"
+ " font-family: monospace;"
+ " border: 1px solid #eee;"
+ " padding: 0;"
+ " margin : 0;"
+ "}"
+ " .cell>a {"
+ " text-decoration: none;"
+ " color: black;"
+ " cursor: help;"
+ "}"
+ " .detail {"
+ " border: 0.2em solid black;"
+ " padding-top: 1em;"
+ " padding-right: 2em;"
+ " padding-left: 2em;"
+ " padding-bottom: 3em;"
+ " background-color: white;"
+ "}"
+ "#tooltip {"
+ " position: fixed;"
+ " bottom: 0;"
+ " right : 0;"
+ "}"
+ " .cell>a:hover {"
+ " background-color: black;"
+ " color: white;"
+ "}"
+ " .format_name {"
+ " height: 1em;"
+ " background-color: #eee;"
+ " padding-right: 0.5em;"
+ " padding-left: 0.5em;"
+ " border-bottom: 1px solid #fff;"
+ "}"
+ " .format_name>a {"
+ " text-decoration: none;"
+ " color: blue;"
+ " cursor: help;"
+ " }"
+ " .format_name>a:hover {"
+ " background-color: blue;"
+ " color: white;"
+ " }"
+
+ "td.component {"
+ " background-color: #060;"
+ " padding-left: 0.5em;"
+ " padding-top: 0.1em;"
+ " padding-bottom: 0.1em;"
+ " overflow: hidden;"
+ " width: 4em;"
+ " color: white;"
+ " border: 1px solid white;"
+ "}"
+ "td.type {"
+ " background-color: #006;"
+ " padding-left: 0.5em;"
+ " padding-top: 0.1em;"
+ " padding-bottom: 0.1em;"
+ " overflow: hidden;"
+ " width: 4em;"
+ " color: white;"
+ " border: 1px solid white;"
+ "}"
+
+ "</style>"
+
+"<script type='text/javascript'>"
+"var tick_count=0;"
+"function tick ()"
+"{"
+" tick_count++;"
+" if (tick_count > 42)"
+" alert(\"Clicking doesn't do anything.\");"
+"}"
+"function hide (id)"
+"{"
+" (document.getElementById (id)).style.display = \"none\";"
+"}"
+"function show (id)"
+"{"
+" (document.getElementById (id)).style.display = \"block\";"
+"}"
+
+"</script>"
+
+
+"</head>\n");
+
+ printf ( "<body>\n");
+
+ printf ("<h1>BablFishPath introspection</h1>");
+ printf ("<p>The table below represents many of the possible conversions available through babl, (the selection of formats includes all formats that shortcut conversions have been registered for.) </p>");
+ printf ("<p>Hover your mouse over a formats name, or a non blank cell on the horizontal line to see further information </p>");
+
+ printf ("<br/><img src='graphics/babl-48x48.png' alt='/babl' />");
+ printf ( "<table cellspacing='0'>\n");
+ babl_format_each (table_source_each, NULL);
+ printf ("</table>");
+
+ printf ("<div id='tooltip'>");
+ babl_format_each (detail_source_each, NULL);
+ babl_format_each (format_each, NULL);
+ printf ("</div>");
+
+ printf ("<div style='height:20em'></div>\n");
+
+ printf ("</body></html>\n");
+
+ babl_destroy ();
+
+ return 0;
+}
--- /dev/null
+/* perform a symmetricality of conversion test on a set of randomized
+ * RGBA data */
+
+#include <stdlib.h>
+#include <math.h>
+#include "babl-internal.h"
+
+#define pixels 1024
+int total_length=0;
+int total_cost=0;
+int total = 0;
+int ok = 0;
+
+static double test[pixels * 4];
+
+static void
+test_init (void)
+{
+ int i;
+
+ for (i = 0; i < pixels * 4; i++)
+ test [i] = (double)random () / RAND_MAX;
+}
+
+static int qux=0;
+
+static char *utf8_bar[]={" ","·","▁","▂","▃","▄","▅","▆","▇","█"};
+//static char *utf8_bar[]= {"!","▁","▃","▅","▇","█","!","!","!"};
+//static char *utf8_bar[]={"·", "█", "▇", "▆", "▅", "▄", "▃", "▂", "▁", };
+//static char *utf8_bar[]={" ","1","2","3","4","5","6","7","8"};
+
+static int destination_each (Babl *babl,
+ void *userdata)
+{
+ Babl *source = userdata;
+ Babl *destination = babl;
+
+ if ((qux++) % babl_formats_count () == qux/ babl_formats_count ())
+ printf (" ");
+ else
+ {
+ Babl *temp = babl_fish_path (source, destination);
+
+ if (temp)
+ {
+ printf ("%s", utf8_bar[temp->fish_path.conversions]);
+ total_length += temp->fish_path.conversions;
+ total_cost += temp->fish_path.cost;
+ ok ++;
+ total ++;
+ }
+ else
+ {
+ printf (" ");
+ total ++;
+ }
+ }
+ return 0;
+}
+
+static int source_no=0;
+
+static int source_each (Babl *babl,
+ void *userdata)
+{
+ babl_format_each (destination_each, babl);
+ printf ("──%2i %s\n", source_no++, babl->instance.name);
+ return 0;
+}
+
+int main (void)
+{
+ babl_init ();
+ test_init ();
+
+ babl_set_extender (babl_extension_quiet_log ());
+ babl_format_each (source_each, NULL);
+ {
+ int i;
+
+ for (i=0;i<babl_formats_count ();i++) printf ("|"); printf ("\n");
+ for (i=0;i<babl_formats_count ();i++) if (i/10==0) printf("|"); else printf ("%i", (i/10)%10); printf ("\n");
+ /* for (i=0;i<babl_formats_count ();i++) printf ("│"); printf ("\n");
+ for (i=0;i<babl_formats_count ();i++) if (i/10==0) printf("│"); else printf ("%i", (i/10)%10); printf ("\n");*/
+ for (i=0;i<babl_formats_count ();i++) printf ("%i", (i)%10); printf ("\n");
+ }
+ printf ("total length: %i\n", total_length);
+ printf ("total cost : %i\n", total_cost);
+ /*printf ("ok / total : %i %i %f\n", ok, total, (1.0*ok) / total);
+ */
+
+ babl_destroy ();
+
+ return 0;
+}
#include <math.h>
#include "babl-internal.h"
-int OK=1;
-
-#define pixels 512
-#define TOLERANCE 0.001
-
#define ERROR_TOLERANCE 0.5
-double test[pixels * 4];
-
-static void
-test_init (void)
-{
- int i;
-
- for (i = 0; i < pixels * 4; i++)
- test [i] = (double)random () / RAND_MAX;
-}
-
-static void
-validate_conversion (BablConversion *conversion)
-{
- Babl *fmt_rgba_double;
- Babl *fmt_source;
- Babl *fmt_destination;
-
- double error=0.0;
-
- void *source;
- void *destination;
- double *destination_rgba_double;
- void *ref_destination;
- double *ref_destination_rgba_double;
-
- fmt_rgba_double = babl_format_new (
- babl_model ("RGBA"),
- babl_type ("double"),
- babl_component ("R"),
- babl_component ("G"),
- babl_component ("B"),
- babl_component ("A"),
- NULL);
- fmt_source = BABL(conversion->source);
- fmt_destination = BABL(conversion->destination);
-
- source = babl_calloc (pixels, fmt_source->format.bytes_per_pixel);
- destination = babl_calloc (pixels, fmt_destination->format.bytes_per_pixel);
- ref_destination = babl_calloc (pixels, fmt_destination->format.bytes_per_pixel);
- destination_rgba_double = babl_calloc (pixels, fmt_rgba_double->format.bytes_per_pixel);
- ref_destination_rgba_double = babl_calloc (pixels, fmt_rgba_double->format.bytes_per_pixel);
-
- babl_process (babl_fish_reference (fmt_rgba_double, fmt_source),
- test, source, pixels);
- babl_process (babl_fish_simple (conversion),
- source, destination, pixels);
-
- babl_process (babl_fish_reference (fmt_source, fmt_destination),
- source, ref_destination, pixels);
-
- babl_process (babl_fish_reference (fmt_destination, fmt_rgba_double),
- ref_destination, ref_destination_rgba_double, pixels);
- babl_process (babl_fish_reference (fmt_destination, fmt_rgba_double),
- destination, destination_rgba_double, pixels);
-
- {
- int i;
- int cnt=0;
-
- for (i=0;i<pixels;i++)
- {
- int j;
- int log=0;
- for (j=0;j<4;j++)
- {
- error += fabs (destination_rgba_double[i*4+j] -
- ref_destination_rgba_double[i*4+j]);
-
- if (fabs (destination_rgba_double[i*4+j] -
- ref_destination_rgba_double[i*4+j])>TOLERANCE)
- log=1;
- }
- if (0 && log && cnt < 5)
- {
- /* enabling this code prints out the RGBA double values at various stages,
- * which are used for the average relative error
- */
-
- babl_log ("%s", conversion->instance.name);
- babl_log ("\ttest: %2.5f %2.5f %2.5f %2.5f", test [i*4+0],
- test [i*4+1],
- test [i*4+2],
- test [i*4+3]);
- babl_log ("\tconversion: %2.5f %2.5f %2.5f %2.5f", destination_rgba_double [i*4+0],
- destination_rgba_double [i*4+1],
- destination_rgba_double [i*4+2],
- destination_rgba_double [i*4+3]);
- babl_log ("\tref_conversion: %2.5f %2.5f %2.5f %2.5f", ref_destination_rgba_double [i*4+0],
- ref_destination_rgba_double [i*4+1],
- ref_destination_rgba_double [i*4+2],
- ref_destination_rgba_double [i*4+3]);
- cnt++;
- OK=0;
- }
- }
- error /= pixels;
- error *= 100;
-
- conversion->error = error;
- if (error >= ERROR_TOLERANCE)
- {
- babl_log ("%s\terror:%f", conversion->instance.name, error);
- OK = 0;
- }
- }
-
-
- babl_free (source);
- babl_free (destination);
- babl_free (destination_rgba_double);
- babl_free (ref_destination);
- babl_free (ref_destination_rgba_double);
-}
+static int OK=1;
static int
each_conversion (Babl *babl,
void *userdata)
{
- Babl *source = BABL(babl->conversion.source);
- Babl *destination = BABL(babl->conversion.destination);
+ double error = babl->conversion.error;
- if (source->instance.id != BABL_RGBA &&
- destination->instance.id != BABL_RGBA &&
- source->instance.id != BABL_DOUBLE &&
- destination->instance.id != BABL_DOUBLE &&
- source->class_type == BABL_FORMAT &&
- destination->class_type == BABL_FORMAT)
- {
- validate_conversion ((BablConversion*)babl);
- }
+ if (error >= ERROR_TOLERANCE)
+ {
+ babl_log ("%s\terror:%f", babl->instance.name, error);
+ OK = 0;
+ }
return 0;
}
int main (void)
{
babl_init ();
- test_init ();
babl_set_extender (babl_extension_quiet_log ());
babl_conversion_each (each_conversion, NULL);
#include <math.h>
#include "babl-internal.h"
-#define pixels 1024
-
-static double test[pixels * 4];
-
-static void
-test_init (void)
-{
- int i;
-
- for (i = 0; i < pixels * 4; i++)
- test [i] = (double)random () / RAND_MAX;
-}
int format_check (Babl *babl,
void *userdata)
{
- void *original;
- double *clipped;
- void *destination;
- double *transformed;
-
- Babl *ref_fmt;
- Babl *fmt;
- Babl *fish_to;
- Babl *fish_from;
-
- ref_fmt = babl_format_new (
- babl_model ("RGBA"),
- babl_type ("double"),
- babl_component ("R"),
- babl_component ("G"),
- babl_component ("B"),
- babl_component ("A"),
- NULL);
-
- fmt = babl;
- fish_to = babl_fish (ref_fmt, fmt);
- fish_from = babl_fish (fmt, ref_fmt);
-
- original = babl_calloc (pixels, fmt->format.bytes_per_pixel);
- clipped = babl_calloc (pixels, ref_fmt->format.bytes_per_pixel);
- destination = babl_calloc (pixels, fmt->format.bytes_per_pixel);
- transformed = babl_calloc (pixels, ref_fmt->format.bytes_per_pixel);
-
- babl_process (fish_to, test, original, pixels);
- babl_process (fish_from, original, clipped, pixels);
- babl_process (fish_to, clipped, destination, pixels);
- babl_process (fish_from, destination, transformed, pixels);
-
- {
- int i;
- double loss=0.0;
-
- for (i=0;i<pixels*4;i++)
- {
- loss += fabs (clipped[i] - test[i]);
- }
- loss /= pixels;
-
- if (userdata)
- babl_log ("%s\tloss: %f", babl->instance.name, loss);
- babl->format.loss = loss;
- }
-
- babl_free (original);
- babl_free (clipped);
- babl_free (destination);
- babl_free (transformed);
+ babl_log ("%s\tloss: %f", babl->instance.name, babl->format.loss);
return 0;
}
int main (void)
{
babl_init ();
- test_init ();
babl_set_extender (babl_extension_quiet_log ());
babl_format_each (format_check, (void*)1);
int OK=1;
-#define pixels 1024
-#define TOLERANCE 0.001
-
-double test[pixels * 4];
-
-double r_interval (double min, double max)
-{
- long int rand_i = random ();
- double ret;
- ret = (double) rand_i / RAND_MAX;
- ret*=(max-min);
- ret+=min;
- return ret;
-}
-
-void test_init (void)
-{
- double r_min = -0.2,
- r_max = 1.5,
- g_min = -0.2,
- g_max = 1.5,
- b_min = -0.2,
- b_max = 1.5,
- a_min = -0.5,
- a_max = 1.5;
- int i;
- double r,g,b,a;
- for (i=0;i<pixels;i++)
- {
- r=r_interval(r_min, r_max);
- g=r_interval(g_min, g_max);
- b=r_interval(b_min, b_max);
- a=r_interval(a_min, a_max);
- test [i*4 + 0]=r;
- test [i*4 + 1]=g;
- test [i*4 + 2]=b;
- test [i*4 + 3]=a;
- }
-}
-
-
-static Babl *reference_format (void)
-{
- static Babl *self = NULL;
-
- if (!self)
- self = babl_format_new (
- babl_model ("RGBA"),
- babl_type ("double"),
- babl_component ("R"),
- babl_component ("G"),
- babl_component ("B"),
- babl_component ("A"),
- NULL);
- return self;
-}
-
-static Babl *construct_double_format (Babl *model)
-{
- void *argument[42+1];
- int args = 0;
- int i;
-
- argument[args++] = model;
- argument[args++] = babl_type ("double");
-
- for (i=0;i<model->model.components; i++)
- {
- argument[args++] = model->model.component[i];
- }
- argument[args++] = NULL;
-
-#define o(argno) argument[argno],
- return babl_format_new (o(0) o(1) o(2) o(3)
- o(4) o(5) o(6) o(7)
- o(8) o(9) o(10) o(11)
- o(12) o(13) o(14) o(15)
- o(16) o(17) o(18) o(19)
- o(20) o(21) o(22) o(23)
- o(24) o(25) o(26) o(27)
- o(28) o(29) o(30) o(31)
- o(32) o(33) o(34) o(35)
- o(36) o(37) o(38) o(39)
- o(40) o(41) o(42) NULL);
-#undef o
-}
int model_check (Babl *babl,
void *userdata)
{
- void *original;
- double *clipped;
- void *destination;
- double *transformed;
-
- Babl *ref_fmt;
- Babl *fmt;
- Babl *fish_to;
- Babl *fish_from;
-
- ref_fmt = reference_format ();
- fmt = construct_double_format (babl);
- fish_to = babl_fish (ref_fmt, fmt);
- fish_from = babl_fish (fmt, ref_fmt);
-
- original = babl_calloc (1,64/8 * babl->model.components * pixels);
- clipped = babl_calloc (1,64/8 * 4 * pixels);
- destination = babl_calloc (1,64/8 * babl->model.components * pixels);
- transformed = babl_calloc (1,64/8 * 4 * pixels);
-
- babl_process (fish_to, test, original, pixels);
- babl_process (fish_from, original, clipped, pixels);
- babl_process (fish_to, clipped, destination, pixels);
- babl_process (fish_from, destination, transformed, pixels);
-
- {
- int i;
- int log=0;
-
- for (i=0;i<pixels;i++)
- {
- int j;
- for (j=0;j<4;j++)
- if (fabs (clipped[i*4+j] - transformed[i*4+j])>TOLERANCE)
- {
- if (!log)
- log=1;
- OK=0;
- }
- if (log && log < 5)
- {
- babl_log ("%s", babl->instance.name);
- babl_log ("\ttest: %2.3f %2.3f %2.3f %2.3f", test [i*4+0],
- test [i*4+1],
- test [i*4+2],
- test [i*4+3]);
- babl_log ("\tclipped: %2.3f %2.3f %2.3f %2.3f", clipped [i*4+0],
- clipped [i*4+1],
- clipped [i*4+2],
- clipped [i*4+3]);
- babl_log ("\ttrnsfrmd: %2.3f %2.3f %2.3f %2.3f", transformed [i*4+0],
- transformed [i*4+1],
- transformed [i*4+2],
- transformed [i*4+3]);
- log++;
- OK=0;
- }
- }
- }
-
- babl_free (original);
- babl_free (clipped);
- babl_free (destination);
- babl_free (transformed);
+ if (!babl_model_is_symmetric (babl))
+ {
+ babl_log ("%s is not symmetric", babl->instance.name);
+ OK=0;
+ }
return 0;
}
+
int main (void)
{
babl_init ();
- test_init ();
babl_set_extender (babl_extension_quiet_log ());
babl_model_each (model_check, NULL);
int OK=1;
-#define TOLERANCE 0.000000001
-#define samples 2048
-double test[samples];
-
-double r_interval (double min, double max)
-{
- long int rand_i = random ();
- double ret;
- ret = (double) rand_i / RAND_MAX;
- ret*=(max-min);
- ret+=min;
- return ret;
-}
-
-void test_init (double min, double max)
-{
- int i;
- for (i=0;i<samples;i++)
- {
- test [i]=r_interval(min,max);
- }
-}
-static Babl *double_vector_format (void)
-{
- static Babl *self = NULL;
-
- if (!self)
- self = babl_format_new (
- babl_model ("Y"),
- babl_type ("double"),
- babl_component ("Y"),
- NULL);
- return self;
-}
-
int type_check (Babl *babl,
void *userdata)
{
-
-
- void *original;
- double *clipped;
- void *destination;
- double *transformed;
-
- Babl *ref_fmt;
- Babl *fmt;
- Babl *fish_to;
- Babl *fish_from;
-
- ref_fmt = double_vector_format ();
- fmt = babl_format_new (babl_model ("Y"),
- babl,
- babl_component ("Y"),
- NULL);
- fish_to = babl_fish (ref_fmt, fmt);
- fish_from = babl_fish (fmt, ref_fmt);
-
- original = babl_calloc (1,babl->type.bits/8 * samples);
- clipped = babl_calloc (1,64/8 * samples);
- destination = babl_calloc (1,babl->type.bits/8 * samples);
- transformed = babl_calloc (1,64/8 * samples);
-
- babl_process (fish_to, test, original, samples);
- babl_process (fish_from, original, clipped, samples);
- babl_process (fish_to, clipped, destination, samples);
- babl_process (fish_from, destination, transformed, samples);
-
- {
- int cnt=0;
- int i;
- for (i=0;i<samples;i++)
- {
- if (fabs (clipped[i] - transformed[i])> TOLERANCE)
- {
- if (cnt++<4)
- babl_log ("%s: %f %f %f)",
- babl->instance.name, test[i], clipped[i], transformed[i]
- );
- OK=0;
- }
- }
- }
-
- babl_free (original);
- babl_free (clipped);
- babl_free (destination);
- babl_free (transformed);
+ if (!babl_type_is_symmetric (babl))
+ {
+ babl_log ("%s is not symmetric", babl->instance.name);
+ OK=0;
+ }
return 0;
}
{
babl_init ();
- test_init (0.0, 182.0);
-
babl_set_extender (babl_extension_quiet_log ());
babl_type_each (type_check, NULL);